package com.rd.student.jiaji.class3.xumingze;

import java.util.*;

public class ManagerSystem
{
    public static <Count> void main(String[] args) {
        LinkedList list = new LinkedList();
        Student Student1 = new Student("王岩博", "3", "jiaji", 47, "ss", "2000");
        Student Student2 = new Student("孙国伟", "3", "jiaji", 32, "hh", "2249");
        Student Student3 = new Student("秦嘉林", "3", "jiaji", 56, "kk", "317");
        Student Student4 = new Student("张世煊", "3", "jiaji", 58, "ii", "500");
        Student Student5 = new Student("才雨鑫", "3", "jiaji", 75, "oo", "500");
        Student Student6 = new Student("徐铭泽", "3", "jiaji", 95, "ll", "500");
        Student Student7 = new Student("孙可", "null", "null", 68, "aa", "1000000");
        list.add(Student1);
        list.add(Student2);
        list.add(Student3);
        list.add(Student4);
        list.add(Student5);
        list.add(Student6);
        list.add(Student7);


        Scanner scanner = new Scanner(System.in);
        System.out.println("请输入一个数来选择你要使用的功能(0:查看小组成员.1:增加成员.2:移除成员.3:根据班级查询成员.4:根据专业查询成员.5:根据年龄查询成员.6:返回所有成员名字.7:计算成员的平均年龄.8:根据年龄范围返回成员.)：");
        int num=scanner.nextInt();
        switch (num){
            case 1:
                AddUtils addUtils = new AddUtils();
                addUtils.addd(list);
                break;
            case 2:
                RemoveUtils removeUtils = new RemoveUtils();
                removeUtils.remoNm(list, "才雨鑫");
                System.out.println(list);
                break;
            case 3:
                break;
            case 4:
                MajorFind majorFind = new MajorFind();
                majorFind.majorFd(list, "jiaji");
                break;
            case 5:
                System.out.println("请输入年龄");
                AgeFind ageFind = new AgeFind();
                ageFind.ageFd(list, ageFind.type);
                break;
            case 6:
                Scanner number = new Scanner(System.in);
                System.out.println("请输入一个数");
                String num1;
                num1 = number.nextLine();
                while (!num1.equals("6")) {
                    System.out.println("你输错了请继续输入");
                    num1 = String.valueOf(number.nextInt());
                }
                System.out.println(Student.NameUtils(list));
                break;
            case 7:
                Student.AgeUtils(list);
                Collections.sort(list, new Comparator<Object>() {
                    @Override
                    public int compare(Object o1, Object o2) {
                        Student d1 = (Student) o1;
                        Student d2 = (Student) o2;

                        if (d1.age < d2.age) {
                            return -1;

                        }
                        if (d1.age > d2.age){
                            return 1;
                        }

                        return 0;
                    }


                });
                for (int i = 0; i < list.size(); i++) {
                    Student s=(Student) list.get(i);
                    System.out.println(s.getAge()+","+s.getName());

                }

//        System.out.println(list);
                System.out.println("----------------------------------------------");
                Collections.reverse(list);
                for (int i = 0; i < list.size(); i++) {
                    Student s=(Student) list.get(i);
                    System.out.println(s.getAge()+","+s.getName());

                }

                break;
            case 8:
                System.out.println("请输入一个数来确定你要取得的年龄范围的最小值");
                int Range=scanner.nextInt();
                System.out.println("请输入一个数来确定你要取得的年龄范围的最大值");
                int Range1=scanner.nextInt();
                System.out.println("下面是年龄在"+Range+"和"+Range1+"之间的成员:");
                System.out.println(Student.ageRange(list,Range,Range1));
                break;
            default:
                System.out.println("请输入正确的数字！");

        }

    }


        public static Student search(ArrayList stu, String cls) {
            for (int i = 0; i < stu.size(); i++) {
                Student s = (Student) stu.get(i);
                if (s.getCls().equals(cls)) {
                    System.out.println(stu.get(i));

                }

            }
            return null;
        }
    }

